package com.example.administrator.myapplication.uilts;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.example.administrator.myapplication.R;

/**
 * Created by 董豪华 on 2017/1/5.
 */
public class ChengshiAdapter extends BaseAdapter {
    Context context;
   private String[] city  = {"贵阳", "安顺","遵义", "六盘水","兴义","铜仁","毕节","都匀"
            ,"昆明" ,"玉溪" ,"大理" ,"曲靖" ,"昭通" ,"保山" ,"丽江" ,"临沧" ,
            "乐山" ,"雅安" ,"广安" ,"南充" ,"自贡" ,"泸州" ,"内江","宜宾" ," 广元" ,"达州" ,"资阳" ,"绵阳" ,"眉山" ,"巴中" ,"攀枝花" ,"遂宁" ,"德阳" ,};

    public ChengshiAdapter(Context context){
       this.context = context;
        setCity(city);
   }
       @Override
    public int getCount() {
        return getCity().length;
    }

    @Override
    public Object getItem(int position) {
        return getCity()[position];
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View view = View.inflate(context,R.layout.chengshi_item,null);
        TextView viewById = (TextView) view.findViewById(R.id.tv_chengshio);
        viewById.setText(getCity()[position]);
        return view;
    }

    public String[] getCity() {
        return city;
    }

    public void setCity(String[] city) {
        this.city = city;
    }
}
